<template>
	<page  ref='page'>
		<!-- 账单明细 wwl-->
		<view class="page">
			<view class="info_box" >
				<!-- <view class="row" v-if="juesetype != 0">
					<text class="">
						总收入：
					</text>
					<text class="money">
						¥{{zongshour}}
					</text>
				</view> -->
				<view class="row" v-if="juesetype == 0">
					<text class="">
						平台返点：
					</text>
					<text class="money">
						¥{{zongtix}}
					</text>
				</view>
				<view class="row" v-if="juesetype != 0">
					<text class="">
						未提现：
					</text>
					<text class="money">
						¥{{yizongtix}}
					</text>
				</view>
				<view class="row" v-if="juesetype != 0">
					<text class="">
						已提现：
					</text>
					<text class="money">
						¥{{zongtix}}
					</text>
				</view>
			</view>
			<view class="list_page" >
				<block v-if='detailed'>
					<view class="list_box" >
						<view class="bottom_box" >
							<view class="row_box" v-for="(item,index) in detailed" :key='index'>
								<view class="left">
									<view class="" >
										<view class="leftorder" v-if='item.type == 1'>
											店铺收入
										</view>
										<view class="leftorder" v-if='item.type == 2'>
											监理金收入
										</view>
										<view class="leftorder" v-if='item.type == 3 && juesetype != 0'>
											平台佣金
										</view>
										<view class="leftorder">
											来源订单：{{item.order.order_no}}
										</view>
										<view class="leftorder">
											来源店铺：{{item.order.shopping_name}}
										</view>
										
										
										<view class="leftorder">
											{{item.created_at}}
										</view>
									</view>
								</view>
								<view class="right">
									
									<view class="money">
										<view class="kaoyou">
											{{item.amount}}
										</view>
										<view class="kaoyou">
											
											<view class="yanse1" v-if='item.status == 1'>
												待提现
											</view>
											<view class="yanse2" v-if='item.status == 2 && item.sub_status == "CREATE_SUCCESS" || item.status == 2 && item.sub_status == "INIT"'>
												受理成功，次日到账
											</view>
											<view class="yanse2" v-if='item.status == 2 && item.sub_status == "FAIL" || item.status == 2 && item.sub_status == "REFUND" || item.status == 2 && item.sub_status == "CLOSE"'>
												提现失败
											</view>
											<view class="yanse3" v-if='item.status == 3 && item.sub_status == "SUCCESS"'>
												提现成功
											</view>
										</view>
										
										
									</view>
								</view>
							</view>
						</view>
					</view>
				</block>
				<empty v-else/>
				<block v-if='openList'>
					<view class="list_box" >
						<view class="bottom_box" >
							<view class="row_box" v-for="(item,index) in openList" :key='index'>
								<view class="left">
									<view class="" >
										<view class="leftorder" v-if='item.type == 1'>
											店铺收入
										</view>
										<view class="leftorder" v-if='item.type == 2'>
											监理金收入
										</view>
										<view class="leftorder" v-if='item.type == 3 && juesetype != 0'>
											平台佣金
										</view>
										<view class="leftorder">
											来源订单：{{item.order.order_no}}
										</view>
										<view class="leftorder">
											来源店铺：{{item.order.shopping_name}}
										</view>
										
										
										<view class="leftorder">
											{{item.created_at}}
										</view>
									</view>
								</view>
								<view class="right">
									
									<view class="money">
										<view class="kaoyou">
											{{item.amount}}
										</view>
										<view class="kaoyou">
											
											<view class="yanse1" v-if='item.status == 1'>
												待分佣
											</view>
											<view class="yanse2" v-if='item.status == 2'>
												正在分佣...
											</view>
											<view class="yanse3" v-if='item.status == 3'>
												已提现到微信零钱
											</view>
											<view class="yanse3" v-if='item.status == 5'>
												分账失败
											</view>
										</view>
										
										
									</view>
								</view>
							</view>
						</view>
					</view>
				</block>
				<empty v-else/>
			</view>
			<foot />
		</view>
	</page>
</template>

<script>
	import {getAccountDetails,getAccountwithdraw} from "../static/api.js"
	export default{
		data(){
			return{
				detailed:[],
				openList:[],
				juesetype:0,
				zongtix:0,
				yizongtix:0,
				zongshour:0,
			}
		},
		computed:{
			userInfo() {
				return this.$store.getters.userInfo
			}
		},
		methods:{
			getOpenList(id){
				if(this.openList.length > 0){
					return this.openList.indexOf(id) != -1 
				}else{
					return false
				}
			},
			setOpenList(id){
				if(this.openList.length > 0){
					this.openList.indexOf(id) == -1  ? this.openList.push(id) :  this.openList.splice(this.openList.indexOf(id),1)
				}else{
					this.openList.push(id)
				}
			},
			async getList(){
				uni.showLoading()
				try{
					var par = [];
					par.juesetype = this.juesetype;
					console.log(par,'aaa');
					var res = await getAccountwithdraw(par)
					console.log(res,'查询数据');
					if(this.juesetype == 0){
						this.openList = res.prouserlist;
					}else{
						this.detailed = res.prouserlist;
						this.openList = res.prouserlist2;
					}
					this.zongtix = res.zongtix;
					this.yizongtix = res.yizongtix;
					this.zongshour = res.zongshour;
					console.log(this.detailed,'商家信息');
					console.log(this.openList,'角色明细');
					// if(res && res.list && res.list.length > 0) this.openList.push(res.list[0].id)
					uni.hideLoading()
				}catch{
					uni.hideLoading()
				}
			},
			onRule(){
				uni.navigateTo({
					url:'/pagesMy/decorationGold/rule'
				})
			}
		},
		onLoad(params){
			this.juesetype = params.juesetype;
			this.getList()
		}
	}
</script>

<style lang="scss" scoped>
	.info_box{
		padding: 20rpx 38rpx 0rpx;
		width: 100%;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
		align-items: center;
		.row{
			flex: 1;
			line-height: 50rpx;
			font-weight: 700;
			>text:nth-child(1){
				font-size: 28rpx;
				color:#26252A;
			}
			.money{
				font-size: 32rpx;
				color:$theme;
			}
			
		}
	}
	.list_page{
		min-height: 60vh;
	}
	.list_box{
		box-shadow: 0px 3px 4px 0px rgba(0,0,0,0.02);
		.top_box{
			padding: 30rpx 38rpx 40rpx;
			width: 100%;
			box-sizing: border-box;
			font-size: 24rpx;
			.time{
				line-height: 34rpx;
				margin-bottom: 16rpx;
			}
			image{
				width: 24rpx;
				height: 24rpx;
				margin-left: 16rpx;
				vertical-align: middle;
			}
			.detailed{
				color:#666;
				line-height: 34prx;
			}
		}
		.bottom_box{
			.row_box{
				border-top: 1px solid #dadada;
				padding-top: 40rpx;
				padding-left: 34rpx;
				width: 100%;
				box-sizing: border-box;
				display: flex;
				justify-content: space-between;
				&:last-child{
					.right{
						border-bottom: 0;
					}
				}
				.left{
					image{
						width: 80rpx;
						height: 80rpx;
						border-radius: 50%;
					}
				}
				.right{
					width: calc(100% - 94rpx);
					box-sizing: border-box;
					padding-bottom: 18rpx;
					padding-right: 38rpx;
					// border-bottom: 2rpx solid #EBEBEF;
					display: flex;
					justify-content: space-between;
					.info{
						width: calc(100% - 200rpx);
						>view:nth-child(1){
							color:#26252A;
							font-size: 32rpx;
							line-height: 44rpx;
							margin-bottom: 8rpx;
						}
						>view:nth-child(2),>view:nth-child(3){
							color:#ADADAD;
							font-size: 24rpx;
							line-height: 34rpx;
						}
						>view:nth-child(2){
							margin-bottom: 24rpx;
						}
						
					}
					.money{
						color:#26252A;
						font-size: 28rpx;
						font-weight: 700;
						text-align: right;
						    width: 100%;
					}
				}
			}
		}
	}
	.leftorder{
		font-size: 12px;
		    width: 210px;
	}
	.kaoyou{
		text-align: right;
	}
	.yanse1{
		color:#ff7800;
	}
	.yanse2{
		color:#c70000;
	}
	.yanse3{
		color:#009806;
	}
</style>
